<?
require('./View/Security.php');
require('./Controller/AdminCheck.php');

if(isset($_POST['true'])) {
	if($_POST['table'] =='CellType') $FrozenTubeColumn = 'CellTypeID';
	if($_POST['table'] == 'Modification') $FrozenTubeColumn = 'ModifiedByID';
	if($_POST['table'] == 'Researcher') $FrozenTubeCoulmn = 'FrozenByID';
	if($_POST['table'] == 'FrozenTube') {
		foreach($_POST['change'] as $modifyName => $modify) {
			foreach($modify as $columnName => $columnValue) {
				// "modify is $modifyName Name is $columnName and value $columnValue </br>";
				if($modify[$columnName] == ""){
					unset($_POST['change'][$modifyName][$columnName]);
				}
				//echo print_r($modifyName);
			}
		}
		updateDatabase('FrozenTube', $_POST['change']['update'], $_POST['change']['remove']);
	} else {
	updateDatabase('FrozenTube', array($FrozenTubeColumn=> $_POST['masterID']), array($FrozenTubeColumn => $_POST['removedID']));
	removeFromDataBase($_POST['table'], array('id' => $_POST['removedID']));
	}
}
?>
<b>WARNING: This page has the ability to make sweeping, irreversable changes to the database.  Be sure you know exactly what you are doing before you start.</b></br>
Choose a Table to merge two item togeather
<form name="merge" action="Merge2.php" method="post">
	<select name="table">
	<option value="CellType" selected="selected">CellType</option>
	<option value="Modification">Modifications</option>
	<option value="Researcher">Researchers</option>
	</select>
<input type="submit" name="Continue">
<a href="Merge3.php">More Narrow Merge Function</a>
</form>